package Tests;



import java.util.ArrayList;

import junit.framework.Assert;

import org.junit.Before;
import org.junit.Test;

import ModelLayer.RealException;
import ModelLayer.Sale;
import ModelLayer.SalesLine;
import ModelLayer.SalesRecords;

public class SalesRecordsTest {
	
	private Sale sale;
	private int saleid;
	private ArrayList<SalesLine> saleLines;
	
	@Before
	public void setUp() throws Exception {
		sale = new Sale();
		sale.setId(1000);
		saleLines = new ArrayList<SalesLine>();
		sale.setSaleLines(saleLines);
		saleid = sale.getId();
	}
	

	@Test
	public void testGetSale() throws RealException {
		SalesRecords.getInstance().getSalesRecords().add(sale);
		Assert.assertEquals(sale, SalesRecords.getInstance().getSale(saleid));
	}
	
	@Test
	public void testRemoveSale() throws RealException {
		SalesRecords.getInstance().getSalesRecords().add(sale);
		SalesRecords.getInstance().removeSale(saleid);
		Assert.assertNotNull(SalesRecords.getInstance().getSale(saleid));
	}
	
	
	@Test
	public void testUpdateSale() throws RealException {
		SalesRecords.getInstance().getSalesRecords().add(sale);
		SalesRecords.getInstance().updateSale(saleid, 3, "0");
		Assert.assertEquals(0, sale.getStartDay());
	}
	
	
}
